//
//  ViewController.m
//  WQFontFitToolDemo
//
//  Created by Xiang on 2021/5/12.
//

#import "ViewController.h"
#import "WQFontFitTool.h"

@interface ViewController ()

@property (nonatomic, strong) UILabel *testLabel;

@property (nonatomic, assign) int fontTypeChangeIndex;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.fontTypeChangeIndex = 1;
    
    self.testLabel = [[UILabel alloc]init];
    [self.view addSubview:self.testLabel];
    self.testLabel.frame = CGRectMake(0, 0, 30, 30);
    self.testLabel.text = @"测试文字测试文字";
    self.testLabel.font = [WQFontFitTool getFontSizeWithType:self.fontTypeChangeIndex size:18];
    [self.testLabel sizeToFit];
    self.testLabel.center = self.view.center;
    
    UIButton *btn = [[UIButton alloc]init];
    [self.view addSubview:btn];
    [btn setTitle:@"改变字体" forState:UIControlStateNormal];
    btn.backgroundColor = UIColor.redColor;
    [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
    btn.frame = CGRectMake(0, 0, 80, 28);
    btn.center = CGPointMake(self.testLabel.center.x, self.testLabel.center.y+80);
    [btn addTarget:self action:@selector(changeFontType) forControlEvents:UIControlEventTouchUpInside];
    
}


- (void)changeFontType{
    if (self.fontTypeChangeIndex == 6) {
        self.fontTypeChangeIndex = 0;
    }
    self.fontTypeChangeIndex ++;
    NSLog(@"self.fontTypeChangeIndex=%d",self.fontTypeChangeIndex);
    self.testLabel.font = [WQFontFitTool getFontSizeWithType:self.fontTypeChangeIndex size:18];
    [self.testLabel sizeToFit];
    self.testLabel.center = self.view.center;
}


@end
